﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BestLifePOS_Core.Data.Commands;
using BestLifePOS_Core.DomainObjects;
using BestLifePOS_Core.Data.Fascade;

namespace BestLifePOS_PresentationLayer
{
    public partial class frmcustomertype : Form
    {
            #region Gloable Variabls

        List<User> GvUserlogindetails = new List<User>();
        string Gvterminalid = "";
        string Gvbranchid = "";
        string Gvcusid = "";
        int Gvflg = 0;

        #endregion

        public frmcustomertype(List<User> userdetails,string terminalid,string branchname)
        {
            InitializeComponent();
            GvUserlogindetails = userdetails;
            Gvterminalid = terminalid;
            Gvbranchid = branchname;
        }

        private void btngo_Click(object sender, EventArgs e)
        {
            #region Check Person who access
            Boolean Lvpassst = false;

            if (txtblaacus.Text.Equals("") && txtidcus.Text.Equals(""))
            {
                Gvcusid ="New Customer";
                Gvflg = 3;
                Lvpassst = true;
            
            }
            else if (txtblaacus.Text.Equals("") && (!txtidcus.Text.Equals(""))) 
            {
                Gvcusid = txtidcus.Text;
                Gvflg = 2;
                Lvpassst = true;
            
            }
            else if ((!txtblaacus.Text.Equals("")) && (txtidcus.Text.Equals("")))
            {
                Gvcusid = txtblaacus.Text;
                Gvflg = 1;
                Lvpassst = true;

            }
            else if ((!txtblaacus.Text.Equals("")) && (!txtidcus.Text.Equals("")))
            {
                MessageBox.Show("Only One Person Can Access One time !!", "Warning", MessageBoxButtons.OK);
                Lvpassst = false;
            }

            //MessageBox.Show("" + Gvcusid + "Flag Is : " + Gvflg);
            #endregion

            if (Lvpassst)
            {
                frm_Best_Life frmBl = new frm_Best_Life(Gvcusid, Gvflg, GvUserlogindetails, Gvterminalid, Gvbranchid);
                frmBl.Show();

            }
        }

        private void frmcustomertype_Load(object sender, EventArgs e)
        {
            lblblacus.Text = "";
        }

        private void txtblaacus_TextChanged(object sender, EventArgs e)
        {
            List<Distributor> Lvlistdistri=DistributorDAO.GetAllDistributors(txtblaacus.Text);

            if (Lvlistdistri.Count > 0)
            {
                foreach (Distributor lvname in Lvlistdistri)
                {
                    lblblacus.Text = lvname.Giv_Name;
                }
            }
            else { lblblacus.Text = ""; }
        }
        
    }
}
